﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using Assist;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YJKRevitBase.WinForm;
using YJKRevitStairs.StairsModel.CommonUnit;

namespace YJKInspectModel.ModelValidation.StairsRamp
{
	public partial class StairsRampValidationForm : System.Windows.Forms.Form
	{
		public StairsRampValidationForm(ComponentTypeManager ComponentTypeManager)
		{
			this.listStairsCheckItem = new List<StairsDataType>();
			this.listRampCheckItem = new List<RampDataType>();
			this.m_ComponentTypeManager = ComponentTypeManager;
			this.InitializeComponent();
			IntPtr mainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
            this._hWndStairsRampValidationForm = new WindowHandle(mainWindowHandle);
		}

		private void StairsRampValidationForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.cmbBuildType.Items.Clear();
			foreach (string item in this.m_ComponentTypeManager.GetUsingRangeList())
			{
				this.cmbBuildType.Items.Add(item);
			}
			if (this.cmbBuildType.Items.Count > 0)
			{
				this.cmbBuildType.SelectedIndex = 0;
			}
			this.chkLandHeight.Checked = true;
			this.chkLandLength.Checked = true;
			this.chkLandWidth.Checked = true;
			this.chkRampHeight.Checked = true;
			this.chkRampLength.Checked = true;
			this.chkRampSlope.Checked = true;
			this.chkRampWidth.Checked = true;
			this.chkRunWidth.Checked = true;
			this.chkStairsHeight.Checked = true;
			this.chkTreadHeight.Checked = true;
			this.chkTreadWidth.Checked = true;
		}

		private void UpdateCheckItem()
		{
			this.listStairsCheckItem.Clear();
			if (this.chkStairsHeight.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_RunHeight);
			}
			if (this.chkLandHeight.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_LandHeight);
			}
			if (this.chkRunWidth.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_RunWidth);
			}
			if (this.chkTreadHeight.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_TreadHeight);
			}
			if (this.chkTreadWidth.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_TreadDepth);
			}
			if (this.chkLandWidth.Checked)
			{
				this.listStairsCheckItem.Add(StairsDataType.SDT_LandWidth);
			}
			this.listRampCheckItem.Clear();
			if (this.chkRampHeight.Checked)
			{
				this.listRampCheckItem.Add(RampDataType.RDT_RampMaxHeight);
			}
			if (this.chkRampSlope.Checked)
			{
				this.listRampCheckItem.Add(RampDataType.RDT_RampSlope);
			}
			if (this.chkRampWidth.Checked)
			{
				this.listRampCheckItem.Add(RampDataType.RDT_RampWidth);
			}
			if (this.chkRampLength.Checked)
			{
				this.listRampCheckItem.Add(RampDataType.RDT_RampLength);
			}
			if (this.chkLandLength.Checked)
			{
				this.listRampCheckItem.Add(RampDataType.RDT_LandLength);
			}
		}

		public List<StairsDataType> GetStairsCheckItem()
		{
			return this.listStairsCheckItem;
		}

		public List<RampDataType> GetRampCheckItem()
		{
			return this.listRampCheckItem;
		}

		public string GetBuildTypeName()
		{
			return this.cmbBuildType.Text;
		}

		private void btnAllSelect_Click(object sender, EventArgs e)
		{
			this.chkStairsHeight.Checked = true;
			this.chkLandHeight.Checked = true;
			this.chkRunWidth.Checked = true;
			this.chkTreadHeight.Checked = true;
			this.chkTreadWidth.Checked = true;
			this.chkLandWidth.Checked = true;
			this.chkRampHeight.Checked = true;
			this.chkRampSlope.Checked = true;
			this.chkRampWidth.Checked = true;
			this.chkRampLength.Checked = true;
			this.chkLandLength.Checked = true;
		}

		private void btnNotSelect_Click(object sender, EventArgs e)
		{
			this.chkStairsHeight.Checked = false;
			this.chkLandHeight.Checked = false;
			this.chkRunWidth.Checked = false;
			this.chkTreadHeight.Checked = false;
			this.chkTreadWidth.Checked = false;
			this.chkLandWidth.Checked = false;
			this.chkRampHeight.Checked = false;
			this.chkRampSlope.Checked = false;
			this.chkRampWidth.Checked = false;
			this.chkRampLength.Checked = false;
			this.chkLandLength.Checked = false;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			this.UpdateCheckItem();
			if (this.listStairsCheckItem.Count == 0 && this.listRampCheckItem.Count == 0)
			{
				YJKMessageBox.Show("请选择检测项", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				return;
			}
			base.DialogResult = DialogResult.OK;
			base.Close();
		}

		private void StairsRampValidationForm_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}

		private List<StairsDataType> listStairsCheckItem;

		private List<RampDataType> listRampCheckItem;

		private ComponentTypeManager m_ComponentTypeManager;

        public WindowHandle _hWndStairsRampValidationForm;
	}
}
